/**
* @Title: integrityMedicalMark_ctrl.js
* @Description: TODO
* Copyright: Copyright (c) 2014 
 * Company:中国平安
*
* @Project HIMS-FWA
* @author EX-XIEYUWEN001
* @date 2014年10月29日 下午14:36:25
* @version V1.0
*/
;
(function(){
	'use strict';
	
	var app = angular.module('fwa.mainApp');
	app.controller('IntegrityMedicalMarkCtrl', ['$scope','$stateParams','BaseURL','Modal','FwaTabsetService','IntegrityMedicalService',
	                                function($scope,$stateParams,baseUrl,Modal,FwaTabsetService,IntegrityMedicalService){
		$scope.form = {};
		$scope.form.date = {};
		var indexNo = 
			'<td>'+
				'{{$index+1}}'+
			'</td>';
		$scope.columns = [
		      		    {label:'序号',map:'no', width:'5%', cellTemplate:indexNo},
		      		    {label:'案件号',map:'caseNo', width:'10%'},
//		      		    {label:'机构名称',map:'healthcareProviderName', width:'15%'},
//		      		    {label:'机构地址',map:'fullAddress', width:'20%'},
		      		    {label:'违规记分值',map:'violationsScores', width:'16%',cellClass:'text-center'},
		      		    {label:'记分原因',map:'reason', width:'15%'},
		      		    {label:'案发日期',map:'happenDate', width:'20%'},
		      		    {label:'暂停医保服务权限时间',map:'suspendPayExecutionTime', width:'20%'},
		      		    {label:'备注',map:'remark',width:'14%'}
		      		 ];
		var params = function (){
			var startDate = "";
			if($stateParams.startDate&&!angular.isUndefined($stateParams.startDate)){
				startDate = $stateParams.startDate;
			}
			var endDate="";
			if($stateParams.endDate&&!angular.isUndefined($stateParams.endDate)){
				endDate = $stateParams.endDate;
			}
			var doctorCode="";
			if($stateParams.doctorCode&&!angular.isUndefined($stateParams.doctorCode)){
				doctorCode = $stateParams.doctorCode;
			}
			var orgCode="";
			if($stateParams.orgCode&&!angular.isUndefined($stateParams.orgCode)){
				orgCode = $stateParams.orgCode;
			}
			var params = {
					startDate:startDate,
					endDate:endDate,
					doctorCode:doctorCode,
					orgCode:orgCode
			}
			return params;
		}
		$scope.queryIntegrityMedicalMark = function (params){
			IntegrityMedicalService.getIntegrityMedicalMark(params).
			success(function(res){
				$scope.tableData = res.integrityMedicalMark;
				$scope.happenDate =   $stateParams.startDate+"~"+$stateParams.endDate;
				$scope.doctorName =  $stateParams.doctorName;
				$scope.certificateNo =  $stateParams.certificateNo;
				$scope.orgName =  $stateParams.orgName;
				$scope.fullAddress =  $stateParams.fullAddress;
			});
		}
		$scope.queryIntegrityMedicalMark(params());
		
		$scope.onReturn = function (){
			var str = 'integrityMedicalDesc.info';
			if($stateParams.flat == '1'){
				str = 'integrityMedicalDesc.info';
			}else if($stateParams.flat == '2'){
				str = 'integrityMedicalTotal.info';
			}
			 FwaTabsetService.selectTab(str,{
				 	doctorCode: $stateParams.doctorCode,
				 	startDate: $stateParams.startDate,
				 	endDate: $stateParams.endDate
				 	},false);
		}
		
		// 导出
		$scope.onExport = function() {
    		$scope.loading = true;
			var par = params();
			var startDate = par.startDate,
			endDate = par.endDate,
			doctorCode = par.doctorCode,
			orgCode = par.orgCode;
			var url= baseUrl+"integrityMedical/integrityMedicalMarkReport.do?startDate="+startDate
			+"&endDate="+endDate+"&doctorCode="+doctorCode+
			"&orgCode="+orgCode+
			"&excelName="+"医务人员纪录_扣分明细导出";
//			var url= baseUrl+"integrityMedical/integrityMedicalMarkReport.do?excelName="+"医务人员纪录_扣分明细导出";
			window.location.href = url;
    		$scope.loading = false;
		}
		
	}]);
})();